﻿using System.Text;
using UwaySoft.EsheetServer.Help.Template;

namespace UwaySoft.EsheetServer.Help.Response
{
    /// <summary>
    /// 工单返回请求模板
    /// </summary>
    public class CheckHangResponse : BaseTemplate, IResponse
    {
        /// <summary>
        /// 请求是否成功，0-成功，1-失败
        /// </summary>
        public string ReturnNo
        {
            get; 
            private set;
        }
        /// <summary>
        /// 客服工单流水号
        /// </summary>
        public string SerialNo
        {
            get; 
            private set;
        }
        /// <summary>
        /// 网优平台工单系统流水号
        /// </summary>
        public string EsheetNo
        {
            get; 
            private set;
        }
        /// <summary>
        /// 返回描述
        /// </summary>
        public string Remark
        {
            get; 
            private set;
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="success">是否成功</param>
        /// <param name="detail">描述</param>
        public CheckHangResponse(bool success, string serialNo, string esheetNo, string remark)
        {
            Remark = remark;
            SerialNo = serialNo;
            EsheetNo = esheetNo;
            ReturnNo = success ? "0" : "-1";
        }
        /// <summary>
        /// 重写ToString
        /// </summary>
        /// <returns>返回XML格式字符串</returns>
        public override string ToString()
        {
            var bldr = new StringBuilder();
            bldr.Append("<?xml version=\"1.0\" encoding=\"gb2312\"?>");
            bldr.Append("<esheet_interface>");
            bldr.Append("<returnInfo>");
            bldr.AppendFormat("<returnNo>{0}</returnNo>", ReturnNo);
            bldr.AppendFormat("<serialNo>{0}</serialNo>", SerialNo);
            bldr.AppendFormat("<esheetNo>{0}</esheetNo>", EsheetNo);
            bldr.AppendFormat("<remark>{0}</remark>", Remark);
            bldr.Append("</ returnInfo >");
            bldr.Append("</esheet_interface>");
            return bldr.ToString();
        }
    }
}
